<template>
    <el-form label-width="100px">
        <el-form-item label="id">
            <div>{{ user.id }}</div>
        </el-form-item>

        <el-form-item label="账号">
            <div>{{ user.loginAct }}</div>
        </el-form-item>

        <el-form-item label="密码">
            <div>********</div>
        </el-form-item>

        <el-form-item label="姓名">
            <div>{{ user.name }}</div>
        </el-form-item>
        <el-form-item label="手机号">
            <div>{{ user.phone }}</div>
        </el-form-item>
         <el-form-item label="邮箱">
            <div>{{ user.email }}</div>
        </el-form-item>
        <el-form-item label="账号是否未过期">
            <div>{{ user.accountNoExpired == 1 ? '是' : '否' }}</div>
        </el-form-item>
         <el-form-item label="密码是否未过期">
            <div>{{ user.credentialsNoExpired == 1 ? '是' : '否' }}</div>
        </el-form-item>
        <el-form-item label="账号是否未锁定">
            <div>{{ user.accountNoLocked == 1 ? '是' : '否' }}</div>
        </el-form-item>
        <el-form-item label="账号是否启用">
            <div>{{ user.accountEnabled == 1 ? '是' : '否' }}</div>
        </el-form-item>
        <el-form-item label="创建时间">
            <div>{{ user.createTime }}</div>
        </el-form-item>
        <el-form-item label="创建人">
            <div>{{ user.createByDo.name }}</div>
        </el-form-item>
        <el-form-item label="更新时间">
            <div>{{ user.editTime }}</div>
        </el-form-item>
        <el-form-item label="更新人">
            <div>{{ user.editByDo.name }}</div>
        </el-form-item>
        <el-form-item label="最后登录时间">
            <div>{{ user.lastLoginTime }}</div>
        </el-form-item>

        <el-form-item >
            <el-button type="primary" @click="goBack">返回</el-button>
        </el-form-item>
    </el-form>
</template>

<script setup>
import { ref,onMounted } from 'vue';
import { useRoute,useRouter } from 'vue-router';
import { doGet } from '../http/httpRequest';
import { showMessage } from '../util/message';



const user = ref({
    //对象类型的属性，需要定义一下
    createByDo:{},
    editByDo:{}
})
//查询用户明细数据
const loadUser = () => {
    //获取用户id  通过url获取用户id
    let id = useRoute().params.userId

    doGet('/api/user/'+id,{}).then(res => {
        if(res.data.code == 200){
            //将用户列表赋值给userPageInfo
            user.value = res.data.info

            //判断创建人是否为空
            if(!res.data.info.createByDo){
                user.value.createByDo = {}
            }
            //判断更新人是否为空
            if(!res.data.info.editByDo){
                user.value.editByDo = {}
            }
        }else{
            showMessage('用户查询失败','error')
        }
    })
}

//页面挂载之后
onMounted(() => {
    loadUser()
})


//声明路由对象
let router = useRouter()
//返回到上一页
const goBack = () => {
    router.back()
}
</script>

<style scoped>
</style>